﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Autofac;

namespace DynCMS.NET.Infrastructure.IOC
{
    /// <summary>
    /// IOC Provider for project
    /// Currently using autofac
    /// </summary>
    public interface IIOCProvider
    {
        void Initialize();

        /// <summary>
        /// Resolves instance of Type
        /// </summary>
        /// <typeparam name="Type">Type to resolve instance</typeparam>
        /// <returns>Instance of type</returns>
        Type Resolve<Type>();

        /// <summary>
        /// Resolves type of service by name
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        Type Resolve<Type>(string name);

        /// <summary>
        /// Registers service implementation
        /// </summary>
        /// <typeparam name="IContract"></typeparam>
        /// <typeparam name="IImplementation"></typeparam>
        void Register<IContract, IImplementation>()
            where IImplementation : IContract
            where IContract : class;

        /// <summary>
        /// Registers service implementation
        /// </summary>
        /// <typeparam name="IContract"></typeparam>
        /// <typeparam name="IImplementation"></typeparam>
        /// <param name="name"></param>
        void Register<IContract, IImplementation>(string name)
            where IImplementation : IContract
            where IContract : class;

        void RegisterAllFromAssemblyContaining<Type>();
    }
}